<template>
  <div v-if="tableData?.length>0">
   <div class="score-container">
    <span>总分： {{total}}</span>
    <span>成熟度等级： {{allGrade}}</span>
  </div>
  <score-table2 :data="tableData" :from="1"></score-table2>
</div>
<div v-else class="table-container__empty">
        <img class="table-container__empty--img" src="@/assets/icons/svg/empty.svg" alt="">
        <div class="table-container__empty--text">还未填写，请耐心等待</div>
      </div>
</template>
<script setup>
import ScoreTable2 from '@/views/components/table/ScoreTable2.vue';
import { getAssessScore } from '@/api/sjhg/assess';
import { ref } from 'vue';
const props = defineProps({
  assessId: {
    type: Number,
    default: 0
  }
})
const tableData = ref([])
const total = ref(0)
const allGrade = ref('-')
onMounted(() => {
  if(props.assessId){
    console.log('===Score onMounted==')
    getScore();
  }
})
const getScore = () => {
    let params = {}
    params.assessId = props.assessId
    getAssessScore(params)
      .then((res) => {
        if (res.code == 200) {
          const list = res.data?.extra
          if(list){
            tableData.value = JSON.parse(list)
            if(tableData.value?.length>0){
              total.value = tableData.value[0].total
              allGrade.value = tableData.value[0].allGrade
            }
          }
        } 
      }).finally(() => {
      });
  }

</script>
<style lang="scss" scoped>
</style>